
#ifndef TP_WIDGET_H
#define TP_WIDGET_H

#include "tp_typedef.h"
#include "tp_event.h"

TP_DECL_BEGIN

struct _TpWidget;
typedef struct _TpWidget TpWidget;

typedef TpRet (*TpWidgetOnEvent)(TpWidget* thiz, TpEvent* event);
typedef void (*TpWidgetDestroy)(TpWidget* thiz);

struct _TpWidget 
{
	TpWidgetOnEvent on_event;
	TpWidgetDestroy destroy;

	int is_show;

	char priv[1];
};

static inline TpRet tp_widget_on_event(TpWidget* thiz, TpEvent* event)
{
	if(NULL == thiz || NULL == event) return TP_RET_BADARGS;

	return thiz->on_event(thiz, event);
}

static inline void tp_widget_destroy(TpWidget* thiz)
{
	if(NULL != thiz && NULL != thiz->destroy)
	{
		thiz->destroy(thiz);
	}

	return;
}

TP_DECL_END

#endif /*TP_WIDGET_H*/
